//
//  BaseController.m
//  LGApplications
//
//  Created by hdz on 2017/6/7.
//  Copyright © 2017年 hdz. All rights reserved.
//

#import "BaseController.h"


@interface BaseController ()


@end

@implementation BaseController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];


    if (!@available(iOS 11.0, *)) self.automaticallyAdjustsScrollViewInsets = NO;
    
    

}

- (void)adjsNavigator
{
    //是否影藏导航底部的线
    if ([self shouldShowShadowImage])
    {
        [self.navigationController.navigationBar setShadowImage:nil];
    }
    else
    {
        [self.navigationController.navigationBar setShadowImage:[UIImage new]];
        [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:(UIBarMetricsDefault)];
    }
    
    if ([self navigationBarBackgroundImage])
    {
        [self.navigationController.navigationBar setBackgroundImage:[self navigationBarBackgroundImage] forBarMetrics:(UIBarMetricsDefault)];
    }
    else
    {
        if ([self navigationColor])
        {
            self.navigationController.navigationBar.barTintColor = [self navigationColor];
        }
        else
        {
            self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
            [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:(UIBarMetricsDefault)];
            
        }
    }
    self.navigationController.navigationBar.translucent = NO;
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[self navigationIsLight]?[UIColor whiteColor]:[UIColor darkTextColor]}];
    self.navigationController.navigationBar.tintColor  = [self navigationIsLight]?[UIColor whiteColor]:[UIColor darkTextColor];
    self.navigationController.navigationBar.barStyle = [self navigationIsLight]?UIBarStyleBlack:UIBarStyleDefault;
}



#pragma mark - config
- (UIImage *)navigationBarBackgroundImage
{
    return nil;
}

- (BOOL)shouldShowShadowImage
{
    return YES;
}
-(UIColor *)navigationColor
{
    return nil;
}

-(BOOL )navigationIsLight
{
    return NO;
}

- (BOOL)isTransparent {
    return NO;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self adjsNavigator];
}


@end
